package File;

import java.io.*;

/**
 * @author wuhan
 * @date 2019/10/11 14:47
 */
public class Demo1 {
    public static void main(String[] args) throws IOException {
//        File f=new File("sa.txt");
//        System.out.println(f.getName());
//        System.out.println(f.length());
//        System.out.println(f.getAbsolutePath());
//        System.out.println(f.getPath());
//        BufferedWriter bf=new BufferedWriter(new FileWriter("sa.txt"));
//        bf.write("asdas");
//        bf.flush();
//        bf.close();
//        System.out.println(f.length());
//        System.out.println(f.getParent());
        listRootsFilterDemo();

    }
    public static void listRootsDemo(){
        File[] files=File.listRoots();
        for (File file : files) {
            System.out.println(file);
        }
    }
    public static void listRootsFilterDemo(){
        File dir=new File("D:\\CXK\\wuhan");
        String[] list = dir.list((dir1, name) -> name.endsWith(".txt"));
        System.out.println(list.length);
        for (String s : list) {
            System.out.println(s);
        }
    }
}
